import { IconifyIcon } from "@iconify/react"

import type { Device } from "@/interface/layout/index.interface"
import type { MenuChild } from "@/interface/layout/menu.interface"

import type { Role } from "./login"
export interface UserInfo {
	active: number
	agentCode: string
	createBy: string
	createdAt: string
	execId: string | null
	googleAuthCode: string | null
	id: number
	idList: Array<string> | null
	merchantCode: string
	merchantId: string
	merchantIdList: Array<string> | null
	nickName: string
	password: string | null
	phone: string
	remark: string | null
	salt: string | null
	status: string | null
	systemType: string | null
	type: string | null
	updatedAt: string | null
	userType: 0 | 1
	username: string | null
	verifyCodeType: number | null
}

export type Locale = "zh_CN" | "en_US"

export interface UserState {
	username: string

	/** menu list for init tagsView */
	menuList: MenuChild[]
	menuData: MenuItem[]

	/** login status */
	logged: boolean

	role: Role

	/** user's device */
	device: Device

	/** menu collapsed status */
	collapsed: boolean

	/** notification count */
	noticeCount: number

	/** user's language */
	locale: Locale

	/** Is first time to view the site ? */
	newUser: boolean

	token: string

	nickName: string

	userInfo: UserInfo

	permissions: string[]

	menus: MenuItem[]

	notices: Record<string, number>
}

export interface Permission {
	id: string
	parentId: string
	permissionName: string
	remark: string | null
	path: string
	isExist?: string | null
	type: string
	orderNum: string
	children?: Permission[] | null
	level: number
	bottom?: Permission[] | null
	perms?: string | null
	sysName?: string | null
	visible: number | null
	isCache: number | null
	menuType: number | null
	icon?: string | null
	component?: string | null
}

export interface MenuItem {
	id: string
	permissionName: string
	orderNum: string
	children: MenuItem[] | null
	component: string
	path: string
	icon: string | IconifyIcon
}
